Log assertions: add assertions for API log errors#1161
Merged
josecelano merged 3 commits intoDec 26, 2024
Merged
Conversation
``` 2024-12-26T09:07:18.149759Z ERROR API: response latency_ms=0 status_code=500 Internal Server Error server_socket_addr=127.0.0.1:41579 request_id=44d8c2f6-630d-4eab-a399-65aed1dbc8ab ```
Now you can send a header `x-request-id` to the API.
```rust
let request_id = Uuid::new_v4();
let response = Client::new(env.get_connection_info())
.get_request_with_query(
"stats",
Query::params([QueryParam::new("token", "")].to_vec()),
Some(headers_with_request_id(request_id)),
)
.await;
```
That ID is recorded in logs. So you can use it to track the request.
Member
Author
|
ACk 5d49d48 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1161 +/- ##
===========================================
+ Coverage 76.07% 76.18% +0.11%
===========================================
Files 174 174
Lines 11601 11601
Branches 11601 11601
===========================================
+ Hits 8825 8838 +13
+ Misses 2613 2606 -7
+ Partials 163 157 -6 ☔ View full report in Codecov by Sentry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It adds test assertions for log errors in the context of the tracker API.
Sample
ERRORlog:cargo test -- --nocapture servers::api::v1::contract::authentication::should_not_authenticate_requests_when_the_token_is_emptyWe are using the
request_idto find the log line because the tracing setup is global (shared by all tests). When the tracker API request is sent, therequest_idis injected as an HTTP header.